package eu.jpereira.trainings.designpatterns.structural.decorator.channel.decorator;

import eu.jpereira.trainings.designpatterns.structural.decorator.channel.SocialChannel;

public class WordCensor extends SocialChannelDecorator{

	private String message;
	
	public WordCensor(String message){
		this.message = message;
	}
	
	public WordCensor(String message, SocialChannel censoredchannel){
		this.message = message;
		this.delegate = censoredchannel;
	}
	@Override
	public void deliverMessage(String message) {
		// TODO Auto-generated method stub
			String str = message.substring(0,message.indexOf(' '));
			str = "###";
			String str2 = message.substring(str.length()+1,message.length());
			StringBuilder builder = new StringBuilder();
			builder.append(str);
			builder.append(str2);
			message = builder.toString();
		delegate.deliverMessage(message);
		
		
	}

}
